package com.yishun.springboot.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import com.yishun.springboot.pojo.GwsAttendanceDTO;
import com.yishun.springboot.pojo.GwsDictListJobName;
import com.yishun.springboot.pojo.GwsProjectAttendanceListNew;
import com.yishun.springboot.pojo.GwsTeam;
import com.yishun.springboot.pojo.GwsTeamType;
import com.yishun.springboot.pojo.YzwProjectAttendanceListNew;
import com.yishun.springboot.pojo.YzwSubContractorList;
import com.yishun.springboot.pojo.YzwWorkerList;

/**
 * 实名制的DB查詢類
 *
 * @author YS
 */
@Component
public interface GwsCWRMapper {

    int updateStatus (@Param(value = "IDCardNumber") String IDCardNumber,@Param(value = "Time") String Time);

    // 获得哪些班组
    List<YzwWorkerList> newSelTeamGroup(@Param(value = "projectCode") Integer projectCode);

    /**
     * 根据项目号和班组号查询 group可任意group一列，例如：SubContractorSysNo
     *
     * @return
     */
    List<YzwWorkerList> newSelWorkerByProjectCodeAndTeamSysNo(@Param(value = "projectCode") Integer projectCode,
                                                              @Param(value = "teamSysNo") Integer teamSysNo, @Param(value = "group") String group);

    /**
     * 根据分包号查询
     *
     * @param subContractorSysNo
     * @return
     */
    YzwSubContractorList newSelSubBySysNo(@Param("subContractorSysNo") Integer subContractorSysNo, @Param("projectCode") Integer projectCode);

    // 根据模糊关键字查询
    GwsDictListJobName selectGwsDictListByLikeValue(String conditions);

    // 根据身份证号查找人员信息
    YzwWorkerList selectGwsWorkerListByGwsIdCardNumber(String gwsIdCardNumber);

    List<GwsProjectAttendanceListNew> selectOneRecordProjectAttendanceListNewByProjectcodeAndIdAndPassedTime(
            @Param(value = "gwsProjectCode") String gwsProjectCode, @Param(value = "iDCardNumber") String iDCardNumber,
            @Param(value = "passedTime") String passedTime);

    /**
     * 根据在线图片路径查找一条考勤数据
     *
     * @param remoteSitePhoto
     * @return
     */
    GwsProjectAttendanceListNew selectOneRecordAttendance(String remoteSitePhoto);

    /**
     * 插入考勤数据-工务署
     *
     * @param gwsProjectAttendanceListNew
     * @return
     */
    int innerOneRecordProjectAttendance(GwsProjectAttendanceListNew gwsProjectAttendanceListNew);

    /**
     * 多少天前考勤数据-云筑网
     *
     * @param iDCardNumber
     * @param timeConditionNum
     * @return
     */
    List<YzwProjectAttendanceListNew> selectAttendancelistnewByIDCardNumberAndConditionTime(
            @Param(value = "iDCardNumber") String iDCardNumber,
            @Param(value = "timeConditionNum") Integer timeConditionNum);

    /**
     * 日期来查考勤数据-云筑网
     *
     * @param iDCardNumber
     * @param timeConditionNum
     * @return
     */
    List<YzwProjectAttendanceListNew> selectAttendancelistnewByIDCardNumberAndTime(
            @Param(value = "iDCardNumber") String iDCardNumber, @Param(value = "time") String time);

    /**
     * 日期来查考勤数据-工务署 貌似已经废弃该mapper：原因是用的比较少几乎没有用好像
     *
     * @param iDCardNumber
     * @param timeConditionNum
     * @return
     */
    List<GwsProjectAttendanceListNew> selectAttendancelistnewByIDCardNumberAndTimeInGws(
            @Param(value = "iDCardNumber") String iDCardNumber, @Param(value = "time") String time);

    List<YzwWorkerList> selectGwsWorkerListByGwsProjectCodeOrIdCardNumber(
            @Param(value = "gwsProjectCode") String gwsProjectCode,
            @Param(value = "gwsWorkerName") String gwsWorkerName);

    int updateLocalImageByIDCardNumber(@Param(value = "localHeadImagePath") String localHeadImagePath,
                                       @Param(value = "localIssueCardPicPath") String localIssueCardPicPath,
                                       @Param(value = "iDCardNumber") String iDCardNumber);

    int truncateDictListJobName();

    int truncateTeamType();

    List<YzwWorkerList> selectPresenceOfWorkerList(@Param(value = "projectCode") Integer projectCode,
                                                   @Param(value = "selectGroupingCondition") String selectGroupingCondition);

    List<YzwWorkerList> selectPresenceOfWorkerList2(@Param(value = "projectCode") Integer projectCode,
                                                    @Param(value = "ExitTime") Boolean ExitTime,
                                                    @Param(value = "selectGroupingCondition") String selectGroupingCondition);

    // 根据条件模糊查询工务署班组类型
    GwsTeamType selectGwsTeamTypeLikeTeamName(String conditions);

    /**
     * 查找所有工种数据
     *
     * @return
     */
    List<GwsDictListJobName> findAllDictListJobName();

    /**
     * 根据order(工务署id)条件查找最近一条或者多条工种数据
     *
     * @param value
     * @return
     */
    GwsDictListJobName findOneDictListJobNameByOrders(String orders);

    /**
     * 插入一条工种数据
     *
     * @param dictListJobName
     * @return
     */
    int innerOneDictListJobNameRecord(GwsDictListJobName dictListJobName);

    GwsTeam findTeamByLikeTeamName(String conditions);

    GwsTeam findTeamByTeamName(String teamName);

    /**
     * 通过云筑网班组名和参建单位营业执照号查找一条记录
     * 理论上yzwTeamName（云筑网班组名）是在上传班组时上传到工务署、同时同步本表的，故此处可以是云筑网班组名等于工务署班组名称
     *
     * @param yzwTeamName
     * @param suid
     * @return
     */
    GwsTeam findOneRecordByYzwTeamNameAndSUID(@Param(value = "yzwTeamName") String yzwTeamName,
                                              @Param(value = "suid") String suid);

    /**
     * 查找所有班组数据
     *
     * @return
     */
    List<GwsTeamType> findTeamTypeAll();

    /**
     * 插入一条班组类型数据
     *
     * @param teamType
     * @return
     */
    int innerOneTeamTypeRecord(GwsTeamType teamType);

    /**
     * 插入工务署班组信息
     *
     * @param gwsTeamId
     * @param gwsTeamName
     * @return
     */
    int innerOneTeamRecord(@Param(value = "gwsProjectcode") String gwsProjectcode,
                           @Param(value = "gwsTeamId") String gwsTeamId, @Param(value = "gwsTeamName") String gwsTeamName,
                           @Param(value = "empCompany") String empCompany, @Param(value = "SUID") String SUID);

    /**
     * 查找所有工种数据
     *
     * @return
     */
    List<Map<String, Object>> findAllDictListJobNameToMap();

    /**
     * 查找所有班组数据
     *
     * @return
     */
    List<Map<String, Object>> findAllTeamTypeToMap();

    List<GwsAttendanceDTO> findByDbTodarAttendance(String serialNumber);

    List<String> findBySerialNumberGroup(Integer projectCode);

}